package com.drg.center.controller;

import com.drg.center.entity.param.BaseIdsDTO;
import com.drg.center.entity.param.SetMatchDTO;
import com.drg.center.entity.result.*;
import com.drg.center.service.SysSettingService;
import com.guaike.core.entity.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("/sysSetting")
@Api(tags = "系统设置接口组")
@AllArgsConstructor
public class SysSettingController {

    private final SysSettingService sysSettingService;

    @GetMapping("/searchHospitalDiagnosis")
    @ApiOperation(value = "搜索院内诊断")
    public Result<List<BaseDictSettingVO>> searchHospitalDiagnosis(@ApiParam("搜索字段，编码/名称") @RequestParam("search") String search) {
        return sysSettingService.searchHospitalDiagnosis(search);
    }

    @GetMapping("/searchMedicalDiagnosis")
    @ApiOperation(value = "搜索医保诊断")
    public Result<List<BaseDictSettingVO>> searchMedicalDiagnosis(@ApiParam("搜索字段，编码/名称") @RequestParam("search") String search) {
        return sysSettingService.searchMedicalDiagnosis(search);
    }

    @GetMapping("/searchMatchDiagnosis")
    @ApiOperation(value = "搜索匹配诊断")
    public Result<List<BaseDictSettingMatchVO>> searchMatchDiagnosis(@ApiParam("搜索字段，编码/名称") @RequestParam("search") String search) {
        return sysSettingService.searchMatchDiagnosis(search);
    }

    @PostMapping("/matchDiagnosis")
    @ApiOperation(value = "匹配诊断")
    public Result<Boolean> matchDiagnosis(@Valid @RequestBody SetMatchDTO param) {
        return sysSettingService.matchDiagnosis(param);
    }

    @PostMapping("/cancelMatchDiagnosis")
    @ApiOperation(value = "取消匹配诊断")
    public Result<Boolean> cancelMatchDiagnosis(@Valid @RequestBody BaseIdsDTO param) {
        return sysSettingService.cancelMatchDiagnosis(param);
    }

    @GetMapping("/searchHospitalOperation")
    @ApiOperation(value = "搜索院内手术")
    public Result<List<BaseDictSettingVO>> searchHospitalOperation(@ApiParam("搜索字段，编码/名称") @RequestParam("search") String search) {
        return sysSettingService.searchHospitalOperation(search);
    }

    @GetMapping("/searchMedicalOperation")
    @ApiOperation(value = "搜索医保手术")
    public Result<List<BaseDictSettingVO>> searchMedicalOperation(@ApiParam("搜索字段，编码/名称") @RequestParam("search") String search) {
        return sysSettingService.searchMedicalOperation(search);
    }

    @GetMapping("/searchMatchOperation")
    @ApiOperation(value = "搜索匹配手术")
    public Result<List<BaseDictSettingMatchVO>> searchMatchOperation(@ApiParam("搜索字段，编码/名称") @RequestParam("search") String search) {
        return sysSettingService.searchMatchOperation(search);
    }

    @PostMapping("/matchOperation")
    @ApiOperation(value = "匹配手术")
    public Result<Boolean> matchOperation(@Valid @RequestBody SetMatchDTO param) {
        return sysSettingService.matchOperation(param);
    }

    @PostMapping("/cancelMatchOperation")
    @ApiOperation(value = "取消匹配手术")
    public Result<Boolean> cancelMatchOperation(@Valid @RequestBody BaseIdsDTO param) {
        return sysSettingService.cancelMatchOperation(param);
    }

    @GetMapping("/searchProject")
    @ApiOperation(value = "搜索项目")
    public Result<List<ProjectVO>> searchProject(@ApiParam("搜索字段，编码/名称") @RequestParam("search") String search,
                                                 @ApiParam("是否重点") @RequestParam("isMain") Boolean isMain,
                                                 @ApiParam("类别（0：项目，1：药品）") @RequestParam("projectType") Integer projectType) {
        return sysSettingService.searchProject(search, isMain, projectType);
    }

    @PostMapping("/setMainProject")
    @ApiOperation(value = "设置重点项目")
    public Result<Boolean> setMainProject(@Valid @RequestBody BaseIdsDTO param) {
        return sysSettingService.setMainProject(param);
    }

    @PostMapping("/cancelMainProject")
    @ApiOperation(value = "取消重点项目")
    public Result<Boolean> cancelMainProject(@Valid @RequestBody BaseIdsDTO param) {
        return sysSettingService.cancelMainProject(param);
    }
}
